<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .box {
            width: 200px;
            height: 200px;
            background-color: #CCC;
            text-align: center;
            color: white;
            font-size: 20px;
        }
    </style>
</head>

<body>
    <div class="box">
        <p>0</p>
    </div>

    <script src="/js/lodash.js"></script>
    <script>
        const box = document.querySelector('.box')
        let i = 0
        function wei() {
            box.innerHTML = i++
        }
        // box.addEventListener('mousemove', _.throttle(wei, 3000))


        // 手写
        function thor() {
            let timer = null
            return function (fn, t) {
                if (!timer) {
                    timer = setTimeout(function () {
                        fn()
                        //清空定时器
                        timer = null
                    }, t)
                }
            }
        }
        box.addEventListener('mousemove', _.throttle(wei, 3000))
    </script>
</body>

</html>